﻿<cfscript>
/** 
* ORM ClassroomType
* 
* @hint "Hibernate persistenter t_classroom_type. HB/JSLX-2006 《教室类型代码》" 
* 
*/ 

component 
	displayname="public.service.orm.senate.ClassroomType" 
	output=false 
	persistent=true 
	selectBeforeUpdate=true dynamicInsert=true dynamicUpdate=true 
	cacheuse="Transactional" 
	entityname="ClassroomType" 
	table="t_classroom_type"
	{

	property type="string" name="Type" column="cr_type" fieldtype="id" generator="assigned" hint="教室类型代码";
	property type="string" name="TypeName" column="cr_type_name" hint="教室类型名称";
	property type="string" name="Usage" column="cr_usage" hint="教室类别用途";
	property type="string" name="SpecialDepartment" column="spec_deps" hint="专用教室类别归属学院";
		
	property name="Classrooms" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cr_type" cfc="Classroom" hint="教室";
	property name="CommonTasks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cr_type" cfc="CommonTask" hint="全校通选课";
	property name="ProgramTasks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cr_type" cfc="ProgramTask" hint="计划课程";
	property name="OpenTasks" type="array" lazy="true" inverse="true" cascade="delete-orphan" fieldtype="one-to-many" fkcolumn="cr_type" cfc="OpenTask" hint="单开班课程";
	
	
	/**
	* @hint "自定义主键规则"
	*/
	public string function getNextID() output=false {
		
		var nextID = "Z" & numberFormat(1, "0_");
		var checkArray = ORMExecuteQuery("select Type from ClassroomType 
											where Type like :condition 
											order by Type desc", { condition="Z" & "__" }, { maxResults=1 });

		/* 
			主键生成规则 CHAR(3)
			
			B + 2位流水号
		*/
		if (arrayLen(checkArray)) {
			/* 创建一个追加id */
			nextID = "Z" & numberFormat((right(checkArray[1], 2) + 1), "0_");
			
		}
		
		return nextID;
	}

}

</cfscript>